#include "qfish.h"

Qfish::Qfish(const QString & fileName,QGraphicsScene *scence):QpimapItem(fileName,scence)
{

}

void Qfish::advance(int phase)
{
    static bool flag=1;
    if(mapToScene(0,0).y()<=0||mapToScene(0,0).x()>=1269||mapToScene(0,0).x()<=0||mapToScene(0,0).y()>=595)
    {
        setPos(qrand()%1269,qrand()%595);flag=1;
    }
    int n,m;
    int speed1=5;
    int speed2=1;
    if(flag)
    {
        speed1=qrand()%10-4;
        speed2=(qrand()%100-qrand()%10)/10-4;
        flag=0;
    }
    n=speed1,m=speed2;
    //倍速
    int b=1;
    this->setPos(mapToScene(n*b,m*b));
}

void Qfish::fish_death()
{
    setPos(qrand()%1000,qrand()%500);
}
